package org.ax.service.sys.imple;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.ax.mapper.sys.PermissionMapper;
import org.ax.mapper.sys.RolePermissionMapper;
import org.ax.pojo.sys.Permission;
import org.ax.pojo.sys.RolePermission;
import org.ax.service.sys.PermissionService;
import org.ax.service.sys.RolePermissionService;
import org.ax.service.sys.RoleService;
import org.springframework.stereotype.Service;

/**
 * 编程人:赵浩鑫
 * 时间:2021-02-23-14:49
 */
@Service
public class IRolePermissionService extends ServiceImpl<RolePermissionMapper, RolePermission> implements RolePermissionService {

    @Override
    public String toRoleIdFindPermissionId(String roleId) {
        QueryWrapper<RolePermission> wrapper=new QueryWrapper<RolePermission>();
        wrapper.eq("sys_role_id", roleId);
        return getBaseMapper().selectOne(wrapper).getSysPermissionId();
    }

    @Override
    public boolean updatePermissionId(RolePermission rolePermission) {
        UpdateWrapper<RolePermission> updateWrapper=new UpdateWrapper<RolePermission>();
        updateWrapper.eq("sys_role_id", rolePermission.getSysRoleId());
        return getBaseMapper().update(rolePermission,updateWrapper)>0;
    }

    @Override
    public boolean addRolePermission(RolePermission rolePermission) {
        return getBaseMapper().insert(rolePermission)>0;
    }

}
